package com.xlq.consultant.tools;

import com.xlq.consultant.entity.Reservation;
import com.xlq.consultant.service.ReservationService;
import dev.langchain4j.agent.tool.P;
import dev.langchain4j.agent.tool.Tool;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Component
public class reservationTools {

    @Resource
    private ReservationService reservationService;

    @Tool("预约志愿填报服务")
    public void addReservation(
            @P("考生姓名") String name,
            @P("考生性别") String gender,
            @P("考生手机号") String phone,
            @P("沟通时间,格式为: yyyy-MM-dd'T'HH:mm") String communicationTime,
            @P("考生所处的省份") String province,
            @P("考生预估分数") Integer estimatedScore
    ) {
        Reservation reservation = new Reservation(null, name, gender, phone, LocalDateTime.parse(communicationTime), province, estimatedScore);
        reservationService.insert(reservation);
    }

    @Tool("根据考生手机号查询预约单")
    public void findByPhone(
            @P("考生手机号") String phone
    ) {
        reservationService.findByPhone(phone);
    }
}
